/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;


import edu.ucsur.tp.sistemainventario.dao.AlmacenDAO;
import edu.ucsur.tp.sistemainventario.beans.Almacen;
import edu.ucsur.tp.sistemainventario.dao.factories.DAOFactory;

/**
 *
 * @author luis.hidalgo
 */
public class frmCreacionAlmacen extends javax.swing.JFrame {
    
    DAOFactory factory = DAOFactory.getInstance(DAOFactory.MY_SQL);

    /**
     * Creates new form frmCreacionAlmacen
     */
    public frmCreacionAlmacen() {
        initComponents();
        this.setLocationRelativeTo(null);
        
        this.jcmDistrito.addItem("ATE");
        this.jcmDistrito.addItem("BARRANCO");
        this.jcmDistrito.addItem("BREÑA");
        this.jcmDistrito.addItem("CERCADO DE LIMA");
        this.jcmDistrito.addItem("CHORRILLOS");
        this.jcmDistrito.addItem("COMAS");
        this.jcmDistrito.addItem("EL AGUSTINO");
        this.jcmDistrito.addItem("INDEPENDENCIA");
        this.jcmDistrito.addItem("JESÚS MARÍA");
        this.jcmDistrito.addItem("LA MOLINA");
        this.jcmDistrito.addItem("LA VICTORIA");
        this.jcmDistrito.addItem("LINCE");
        this.jcmDistrito.addItem("LOS OLIVOS");
        this.jcmDistrito.addItem("MAGDALENA DEL MAR");
        this.jcmDistrito.addItem("MIRAFLORES");
        this.jcmDistrito.addItem("PUEBLO LIBRE");
        this.jcmDistrito.addItem("PUENTE PIEDRA");
        this.jcmDistrito.addItem("RIMAC");
        this.jcmDistrito.addItem("SAN BORJA");
        this.jcmDistrito.addItem("SAN ISIDRO");
        this.jcmDistrito.addItem("SAN JUAN DE LURIGANCHO");
        this.jcmDistrito.addItem("SAN JUAN DE MIRAFLORES");
        this.jcmDistrito.addItem("SAN LUIS");
        this.jcmDistrito.addItem("SAN MARTIN DE PORRES");
        this.jcmDistrito.addItem("SAN MIGUEL");
        this.jcmDistrito.addItem("SANTA ANITA ");
        this.jcmDistrito.addItem("SANTA ROSA");
        this.jcmDistrito.addItem("SANTIAGO DE SURCO");
        this.jcmDistrito.addItem("SURQUILLO");
        this.jcmDistrito.addItem("VILLA EL SAVADOR");
        this.jcmDistrito.addItem("VILLA MARÍA DEL TRIUNFO");
               
        
        this.jcmbProvincia.addItem("BARRANCA");
        this.jcmbProvincia.addItem("CANTA");
        this.jcmbProvincia.addItem("CHACLACAYO");
        this.jcmbProvincia.addItem("CHANCAY");
        this.jcmbProvincia.addItem("CHICLA");
        this.jcmbProvincia.addItem("CHOSICA");
        this.jcmbProvincia.addItem("HUACHO");
        this.jcmbProvincia.addItem("HUALMAY");
        this.jcmbProvincia.addItem("HUARAL");
        this.jcmbProvincia.addItem("HUAURA");
        this.jcmbProvincia.addItem("IMPERIAL");
        this.jcmbProvincia.addItem("LIMA");
        this.jcmbProvincia.addItem("LUNAHUANÁ");
        this.jcmbProvincia.addItem("MAGDALENA");
        this.jcmbProvincia.addItem("MALA");
        this.jcmbProvincia.addItem("MARCAHUASI");
        this.jcmbProvincia.addItem("MATUCANA");
        this.jcmbProvincia.addItem("MIRAFLORES");
        this.jcmbProvincia.addItem("NUEVO IMPERIAL");
        this.jcmbProvincia.addItem("OYÓN");
        this.jcmbProvincia.addItem("PARAMONGA");
        this.jcmbProvincia.addItem("PATIVILCA");
        this.jcmbProvincia.addItem("PUNTA HERMOSA");
        this.jcmbProvincia.addItem("QUILMANÁ");
        this.jcmbProvincia.addItem("RICARDO PALMA");
        this.jcmbProvincia.addItem("SAN LUIS");
        this.jcmbProvincia.addItem("SAN VICENTE DE CAÑETE");
        this.jcmbProvincia.addItem("SANTA EULALIA");
     
        this.jcmbDepartamento.addItem("AMAZONAS"); 
        this.jcmbDepartamento.addItem("ANCASH");
        this.jcmbDepartamento.addItem("APURIMAC"); 
        this.jcmbDepartamento.addItem("AREQUIPA"); 
        this.jcmbDepartamento.addItem("AYACUCHO"); 
        this.jcmbDepartamento.addItem("CAJAMARCA"); 
        this.jcmbDepartamento.addItem("CUSCO");
        this.jcmbDepartamento.addItem("CALLAO");
        this.jcmbDepartamento.addItem("HUANCAVELICA"); 
        this.jcmbDepartamento.addItem("HUANUCO");
        this.jcmbDepartamento.addItem("ICA"); 
        this.jcmbDepartamento.addItem("JUNIN"); 
        this.jcmbDepartamento.addItem("LA LIBERTAD"); 
        this.jcmbDepartamento.addItem("LAMBAYEQUE"); 
        this.jcmbDepartamento.addItem("LIMA"); 
        this.jcmbDepartamento.addItem("LORETO"); 
        this.jcmbDepartamento.addItem("MADRE DE DIOS"); 
        this.jcmbDepartamento.addItem("MOQUEGUA"); 
        this.jcmbDepartamento.addItem("PASCO"); 
        this.jcmbDepartamento.addItem("PIURA"); 
        this.jcmbDepartamento.addItem("PUNO"); 
        this.jcmbDepartamento.addItem("SAN MARTIN"); 
        this.jcmbDepartamento.addItem("TACNA"); 
        this.jcmbDepartamento.addItem("TUMBES"); 
        this.jcmbDepartamento.addItem("UCAYALI");
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jcmDistrito = new javax.swing.JComboBox();
        jcmbProvincia = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jcmbDepartamento = new javax.swing.JComboBox();
        jtxtDireccion = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jtxtNombre = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtxaComentarios = new javax.swing.JTextArea();
        jbtnAceptar = new javax.swing.JButton();
        jbtnSalir = new javax.swing.JButton();
        jtxtCodigo = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Creación de Almacenes");

        jLabel2.setText("Nombre del Almacén:");

        jLabel8.setText("Distrito:");

        jLabel7.setText("Provincia:");

        jLabel4.setText("Departamento:");

        jcmbDepartamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcmbDepartamentoActionPerformed(evt);
            }
        });

        jLabel3.setText("Direccion:");

        jLabel5.setText("Comentarios:");

        jLabel6.setText("Codigo:");

        jtxaComentarios.setColumns(20);
        jtxaComentarios.setRows(5);
        jScrollPane1.setViewportView(jtxaComentarios);

        jbtnAceptar.setText("ACEPTAR");
        jbtnAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnAceptarActionPerformed(evt);
            }
        });

        jbtnSalir.setText("CANCELAR");
        jbtnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1)
                    .addComponent(jSeparator1)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 205, Short.MAX_VALUE)
                        .addComponent(jbtnAceptar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jbtnSalir))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel7)
                            .addComponent(jLabel8)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6))
                        .addGap(22, 22, 22)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtxtNombre)
                            .addComponent(jtxtDireccion)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jcmDistrito, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jcmbProvincia, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jcmbDepartamento, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jtxtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jtxtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtxtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtxtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel7)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel8))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jcmbDepartamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jcmbProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jcmDistrito, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtnAceptar)
                    .addComponent(jbtnSalir))
                .addGap(21, 21, 21))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSalirActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
    }//GEN-LAST:event_jbtnSalirActionPerformed

    private void jcmbDepartamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmbDepartamentoActionPerformed
        // TODO add your handling codcme here:
    }//GEN-LAST:event_jcmbDepartamentoActionPerformed

    private void jbtnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAceptarActionPerformed
        // TODO add your handling code here:
        Almacen alm = new Almacen();
        
        alm.setCodigo(jtxtCodigo.getText());
        alm.setNombre(jtxtNombre.getText());
        alm.setDireccion(jtxtDireccion.getText());
        alm.setDepartamento(jcmbDepartamento.getName());
        alm.setProvincia(jcmbProvincia.getName());
        alm.setDistrito(jcmDistrito.getName());
        alm.setComentarios(jtxaComentarios.getText());
        
        AlmacenDAO almacenDAO = factory.getAlmacen();
        almacenDAO.insertarAlmacen(alm);
    }//GEN-LAST:event_jbtnAceptarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frmCreacionAlmacen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frmCreacionAlmacen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frmCreacionAlmacen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frmCreacionAlmacen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new frmCreacionAlmacen().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JButton jbtnAceptar;
    private javax.swing.JButton jbtnSalir;
    private javax.swing.JComboBox jcmDistrito;
    private javax.swing.JComboBox jcmbDepartamento;
    private javax.swing.JComboBox jcmbProvincia;
    private javax.swing.JTextArea jtxaComentarios;
    private javax.swing.JTextField jtxtCodigo;
    private javax.swing.JTextField jtxtDireccion;
    private javax.swing.JTextField jtxtNombre;
    // End of variables declaration//GEN-END:variables

    

}
